{% extends "base.html" %}{% load bootstrap3 %}

{% block page_header %}
  <div class="page-header">
    <h1>{{ post.title }}</h1>
  </div>
{% endblock %}

{% block content %}
  {% if post.body and not post.author %}
    <p>{{ post.body|linebreaksbr }}<p>
  {% endif %}
  {% if post.embed_code %}
    {{ post.embed_code|safe }}
  {% endif %}
  {% if post.image %}
    <p><img src="{% url 'image_file' slug=post.slug %}" width="{{ post.image.size.0 }}" height="{{ post.image.size.1 }}" /><p>
  {% endif %}
  {% if post.music_parameters %}
    <p><a href="{{ post.url }}">Check out this song !</a></p>
    <p>Music info :<br/>
      <ul>
      {% for key, value in post.music_parameters.items %}
        <li>{{ key }} :
          {% if value.items %}
            <ul>
              {% for k, v in value.items%}
                <li>{{ k }} : {{ v }}</li>
              {% endfor %}
            </ul>
          {% else %}
            {{ value }}
          {% endif %}
        </li>
      {% endfor %}
      </ul>
    </p>
  {% endif %}
  {% if post.author %}
    <blockquote>{{ post.body|linebreaksbr }}</blockquote>
    <p>{{ post.author }}</p>
  {% endif %}
  <p>{{ post.created_at }}</p>
  {% block aftercontent %}
  <div class="btn-group">
    <a href="{% url 'post_update' slug=post.slug %}" class="btn btn-default"><i class="glyphicon glyphicon-edit"></i> edit</a>
    <a href="{% url 'post_delete' slug=post.slug %}" class="btn btn-default"><i class="glyphicon glyphicon-remove"></i> delete</a>
  </div>
  <hr>
  <h2>Comments</h2>
  {% if post.comments %}
    {% for comment in post.comments %}
       <p>{{ comment.body }}</p>
       <p><strong>{{ comment.author }}</strong> <small>on {{ comment.created_at }}</small></p>
      {{ comment.text }}
    {% endfor %}
  {% else %}
    <p>No comments, be the first to comment!</p>
  {% endif %}
  <h2>Add a comment</h2>
  <form class="form" action="." method="post">
    {% csrf_token %}
    {% bootstrap_form form %}
    <div class="actions">
      <input type="submit" class="btn primary" value="comment">
    </div>
  </form>
  {% endblock %}

  {{ embedded_form }}
{% endblock %}
